<h1>
	<? if(isset($category['Category']['id'])): ?>
		Izmena kategorije proizvoda #<?= $category['Category']['id'] ?>
	<? else: ?>
		Nova kategorija proizvoda
	<? endif; ?>
</h1>
<?= $this->Html->link('&laquo; Nazad', '/admin_products/categories', array('escape'=>false)) ?>

<?= $this->Form->create('Category', array('url'=>'/admin_products/category_save', 'enctype'=>'multipart/form-data')) ?>
	<?= $this->Form->hidden('id', array('value'=>@$category['Category']['id'])) ?>
	
	<?
	   $categoryId = (int)@$category['Category']['id'];
	   if ($categoryId) {
	       unset($allcategories[$categoryId]);
	   }
	?>
	<?= $this->Form->label('parent_id', 'Roditelj kategorija:') ?>
    <?= $this->Form->select('parent_id', $allcategories, array(
        'value' => @$category['Category']['parent_id'],
        'empty' => ' --- '
    )) ?>
	
	<?= $this->Form->label('name', 'Naziv:') ?>
	<?= $this->Form->text('name', array('value'=>@$category['Category']['name'])) ?>
	<?= $this->Form->error('name') ?>
	
	<?= $this->Form->label('CategoryImage.file', 'Slika:') ?>
	<?= $this->Form->hidden('image', array('value'=>@$category['Category']['image'])) ?>
	<p><?= $this->Html->image('categories/'.@$category['Category']['image'], array('width'=>180)) ?><br>
	<?= $this->Form->file('CategoryImage.file') ?></p>
	
    <?= $this->Form->label('description', 'Kratak opis:') ?>
    <?= $this->Form->textarea('description', array('value'=>@$category['Category']['description'])) ?>
	
	<br clear="all">
	<?= $this->Form->submit('Sačuvaj', array('div'=>false)) ?>
	<?= $this->Form->submit('Poništi', array('onclick'=>"location.href='/admin_products/categories'", 'type'=>'button', 'div'=>false)) ?>
	<? if ($categoryId): ?>
	   <?= $this->Form->submit('Obriši kategoriju', array('onclick'=>"if(confirm('Da li želite da obrišete kategoriju: {$category['Category']['name']}?')) location.href='/admin_products/category_delete/{$categoryId}'", 'type'=>'button', 'div'=>false)) ?>
	<? endif ?>
<?= $this->Form->end() ?>